package GUI;

import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import conference.TextParse;

import papers.Manuscript;

/**
 * A class that allow to change the manuscript status.
 * @author Dickson Kwong
 * @version v1.2 Nov. 30, 2011
 */

@SuppressWarnings("serial")
public class PCViewManuRevPanel extends JPanel {

	/**
	 * The PCViewManuRevPanel Constructor. It creates a view
	 * the manuscript & review contact.
	 * @param the_manuscript The manuscript
	 */
	public PCViewManuRevPanel(Manuscript the_manuscript) {
	    super(true);
	    setLayout(new BorderLayout());
	    setSize(200, 500);
	    setup(the_manuscript);
	}
	
	/**
	 * It add all the necessary panels to the frame.
	 * @param the_manuscript The manuscript
	 */
	private void setup(Manuscript the_manuscript){
	    StringBuilder sb = new StringBuilder();
	    sb.append(TextParse.getText(the_manuscript));
	    
	    JTextArea textArea = new JTextArea(22,45);
	    textArea.setText(sb.toString());
	    textArea.setLineWrap(true);
	    textArea.setWrapStyleWord(true);
	    textArea.setCaretPosition(0);
	    JScrollPane areaScrollPane = new JScrollPane(textArea);
	    areaScrollPane.setVerticalScrollBarPolicy(
	                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	    areaScrollPane.setEnabled(true);
	    textArea.setEditable(false);
	    add(areaScrollPane, BorderLayout.WEST);
	    
	    sb = new StringBuilder();
	    sb.append(TextParse.getRevText(the_manuscript));
		
	    if(the_manuscript.getReviews().size() == 0){
			sb.append("No Review.");
		}

		JLabel space = new JLabel("        ");
		add(space);
	    JTextArea reviewArea = new JTextArea(22,45);
	    reviewArea.setText(sb.toString());
	    reviewArea.setLineWrap(true);
	    reviewArea.setWrapStyleWord(true);
	    reviewArea.setCaretPosition(0);
	    JScrollPane areaScrollPane2 = new JScrollPane(reviewArea);
	    areaScrollPane2.setVerticalScrollBarPolicy(
	                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	    areaScrollPane2.setEnabled(true);
	    reviewArea.setEditable(false);
	    add(areaScrollPane2, BorderLayout.EAST);
	}
}
